<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,viewport-fit=cover,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>尤迈桃李会</title>
    <script src="js/rem.js"></script>
    <link rel="stylesheet" href="css/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.min.css">
    <link rel="stylesheet" href="css/public.css">
    <link rel="stylesheet" href="css/user.css">
    <script>(function() {var _53code = document.createElement("script");_53code.src = "https://tb.53kf.com/code/code/96d8f960b261e49515450f8953b044bc5/1";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(_53code, s);})();</script>
</head>
<body>
    <!-- 医生会诊病例详情 -->
    <div class="pub-container user-consultation bgwhite">
        <div class="main" id="main">
        </div>
    </div>
    <!-- 图片预览弹窗 -->
    <div class="img-pre popup">
        <div class="cont1">
            <div class="img-wrapper">
                <img>
            </div>
        </div>
    </div>
    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/swiper.min.js"></script>
    <script src="js/jquery-weui.min.js"></script>
    <script src="js/hammer.js"></script>
    <script src="js/md5.js"></script>
    <script src="js/public.js"></script>
    <script>
        var detailType = getQueryString('type');
        var url = detailType === '1' ? '/consulation/queryConsultDetailById' : '/consulation/queryResultDetail';
        getDetail();
        function getDetail(){
            http(url, {
                hasToken: true,
                data: {
                    specialistId: Number(getQueryString('specialistId'))
                },
                success: function(res){
                    if(res.code === '01'){
                        var data = res.data, html = '', 
                            doctor = data.doctors ? data.doctors[0] : null, 
                            diseaseList = data.diseaseList, 
                            imgList = [], 
                            fileList = [];
                        diseaseList.forEach(function(item){
                            const fileType = item.fileName.replace(/.+\./,"").toLowerCase();
                            if(/(png)|(jpg)|(jpeg)|(gif)/.test(fileType)){
                                imgList.push(item);
                            }else {
                                fileList.push(item);
                            }
                        })
                        html += '<div class="consultation-info space-border plr15">' + 
                            '<div class="user-box box1">' + 
                                '<p class="consultation-time">申请时间<span>' + format(data.consultTime) + '</span></p>' + 
                                '<a class="custom-btn" href="' + customUrl + '">咨询客服</a>' + 
                            '</div>' + 
                            '<div class="user-box box5">' + 
                                '<h4 class="user-pub-tit">基本信息</h4>' + 
                                '<div class="box5-wrapper">' + 
                                    '<p class="line1"><span>' + data.patientName +'</span><span>' + SEXDINC[data.patientSex] + '</span><span>' + data.patientAge + '岁</span><span>' + data.patientNation + '</span><span>' + data.patientHight + 'cm</span><span>' + data.patientWeight + 'kg</span></p>' + 
                                    '<p class="line"><span class="pr20">患者电话</span><span>' + phoneDesensitization(data.patientPhone) +'</span></p>' + 
                                    '<p class="line"><span class="pr20">患者身份证号</span><span>' + cardDesensitization(data.patientNumber) +'</span></p>' + 
                                    '<p><span class="pr20">入院日期</span><span>' + format(data.enterHospital) +'</span></p>' + 
                                '</div>' + 
                            '</div>' + 
                        '</div>' + 
                        '<div class="consultation-info space-border plr15">' + 
                            '<div class="user-box box3">';
                            if(doctor){
                                html += '<h4 class="user-pub-tit">申请信息</h4>' + 
                                '<div class="sq-info">' + 
                                    '<p><span class="txt1">申请科室:</span><span>' + doctor.departmentCode +'</span></p>' + 
                                    '<p><span class="txt1">申请医生:</span><span>' + doctor.userName +'</span></p>' + 
                                    '<p><span class="txt1">医生职称:</span><span>' + doctor.competent +'</span></p>' + 
                                    '<p><span class="txt1">医生电话:</span><span>' + phoneDesensitization(doctor.loginMobile) +'</span></p>';
                                    if(detailType === '2' && data.message){
                                        var type = data.message.type
                                        html += '<p><span class="txt1">会诊方式:</span><span>' + CONSUTATIONTYPE[type] + '</span></p>';
                                        if(type == 0){
                                            html += '<p><span class="txt1">会诊地址:</span><span>' + item.consulationAddress + '</span></p>';
                                        }
                                    }
                                html += '</div>';
                            }
                            html += '<p class="title">咨询目的</p>' + 
                                '<p class="purpose">' + data.consultMessage +'</p>' + 
                            '</div>' + 
                        '</div>' + 
                        '<div class="consultation-info space-border plr15">' + 
                            '<div class="user-box box3">' + 
                                '<div class="see-wrapper">' + 
                                    '<h4 class="user-pub-tit">会诊病例</h4>' + 
                                    // '<a class="see-btn" href="#">修改病例</a>' + 
                                '</div>' + 
                                '<ul class="see-list">' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">诊 断</p>' + 
                                        '<p class="txt2">' + data.diagnose +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">主 诉</p>' + 
                                        '<p class="txt2">' + data.complain +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">现病史</p>' + 
                                        '<p class="txt2">' + data.nowHistory +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">既往史</p>' + 
                                        '<p class="txt2">' + data.formerlyHistory +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">个人史</p>' + 
                                        '<p class="txt2">' + data.myHistory +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">家族史</p>' + 
                                        '<p class="txt2">' + data.familyHistory +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">体格检查</p>' + 
                                        '<p class="txt2">' + data.sportCheck +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">专科检查</p>' + 
                                        '<p class="txt2">' + data.specialCheck +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">辅助检查</p>' + 
                                        '<p class="txt2">' + data.helpCheck +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">目前治疗方案</p>' + 
                                        '<p class="txt2">' + data.schemas +'</p>' + 
                                    '</li>' + 
                                    '<li>' + 
                                        '<p class="last-text-justify">治疗效果</p>' + 
                                        '<p class="txt2">' + data.treament +'</p>' + 
                                    '</li>' + 
                                '</ul>' + 
                                '<p class="title">会诊目的</p>' + 
                                '<p class="purpose">' + data.plan +'</p>' + 
                                '<div class="download-wrapper">' + 
                                    '<h4 class="user-pub-tit border-bottom">其他检查及检验报告</h4>';
                                    var imgLen = imgList.length;
                                    if(imgLen > 0){
                                        html += '<div class="swiper-box swiper-fixed"><div class="swiper-container detail-swiper">' + 
                                            '<div class="swiper-wrapper">';
                                                imgList.forEach(function(item, index){
                                                    html += '<div class="swiper-slide">' + 
                                                        '<img src="' + item.uploadUrl + '" alt="">' + 
                                                        '<div class="info">' + 
                                                            '<p class="cut1">' + item.fileName + '</p>' + 
                                                            '<p>' + (index + 1) + '/' + imgLen + '</p>' + 
                                                        '</div>' + 
                                                    '</div>';
                                                })
                                        html += '</div>' + 
                                        '</div></div>';
                                    }
                                    html += '<ul>';
                                        var fileLen = fileList.length;
                                        if(fileLen > 0){
                                            fileList.forEach(function(item, index){
                                                html += '<li>' + 
                                                    '<div class="file-info">' + 
                                                        '<p class="file-name cut1">' + item.fileName + '</p>' + 
                                                        '<p class="type-tip cut1">图片、pdf、word、excel</p>' + 
                                                    '</div>' + 
                                                    '<a class="pub-bth" download="' + item.fileName + '" href="' + item.uploadUrl + '">下载</a>' + 
                                                '</li>'
                                            })
                                            
                                        }
                                    html += '</ul>' + 
                                '</div>' + 
                            '</div>' + 
                        '</div>' + 
                        '<div class="consultation-info plr15">' + 
                            '<div class="user-box box6">' + 
                                '<h4 class="user-pub-tit">其他检查及检验报告小提示</h4>' + 
                                '<div class="tip-list">' + 
                                    '<p>1.神经科需要提供如：头CT、核磁等相关检查；</p>' + 
                                    '<p>2.呼吸科需要提供如：痰涂片、痰培养、肺炎支原体抗体、胸部C T（肺窗、纵膈窗）、核磁、肺功能等检查等；</p>' + 
                                    '<p>3.消化内科需要提供如：腹部超声、腹部CT、胃肠镜等；</p>' + 
                                    '<p>4.心内科需要提供如：心电图、超声心动、Holter检查等； </p>' + 
                                    '<p>5.内分泌科如糖尿病需提供如：三餐前后的血糖监测结果、糖化 血红蛋白、胰岛素释放试验、C肽释放试验、眼底等；</p>' + 
                                    '<p>6.骨科需要提供如：相关部位X线（正位、侧位）CT、核磁等；</p>' + 
                                    '<p>7.妇科需要提供如：月经婚育史、激素水平、阴道分泌物常规检测 子宫附件超声等；</p>' + 
                                    '<p>8.肿瘤科需要提供如：CT、核磁、病理等，有手术的需 要提供详细手术记录（包括浸润深度、边缘情况等）；</p>' + 
                                    '<p>9.血管外科有下肢血栓的需要提供如：下肢超声检查</p>' + 
                                '</div>' + 
                            '</div>';
                                if(detailType === '2' && data.resultMessage){
                                    html += '<div class="user-box box3 border-top">' + 
                                        '<p class="title">会诊意见</p>' + 
                                        '<p class="purpose">' + data.resultMessage.adviceMessage +'</p>' + 
                                        '<div class="img-list">';
                                    data.resultMessage.fileList.forEach(function(item){
                                        html += '<img src="' + item.uploadUrl + '" alt="' + item.uploadName + '">';
                                    })
                                    html += '</div>' + 
                                    '</div>';
                                }

                        html += '</div>';
                        $('#main').html(html);
                        var $swiper = $(".swiper-box .detail-swiper");
                        $swiper.swiper();
                    }
                }
            });
        }
        $(document.body).on('click', '.swiper-box .swiper-slide > img', function(e){
            preImg(e);
        })
        $(document.body).on('click', '.img-list > img', function(e){
            preImg(e);
        })
        function preImg(e){
            var src = $(e.currentTarget).attr('src');
            $('.img-pre.popup img').attr('src', src);
            $('.img-pre.popup').show();
            drag('.img-pre.popup img');
        }
        function drag(drag) {
            var reqAnimationFrame = (function () {
                return window[Hammer.prefixed(window, 'requestAnimationFrame')] || function (callback) {
                    window.setTimeout(callback, 1000 / 60);
                };
            })();

            var el = document.querySelector(drag);

            var START_X = 0;
            var START_Y = 0;

            var ticking = false;
            var transform; //图像效果
            var timer;
            var initAngle = 0; //旋转角度
            var initScale = 3; //放大倍数

            var mc = new Hammer.Manager(el); //用管理器 可以同时触发旋转 拖拽 移动
            //var mc = new Hammer(el); //旋转和移动互斥
            /**
            ev.srcEvent.type touchstart touchend touchmove
            ev.deltaX 手势移动位移变量 
            */
            mc.add(new Hammer.Pan({ threshold: 0, pointers: 0 }));
            mc.add(new Hammer.Rotate({ threshold: 0 })).recognizeWith(mc.get('pan'));
            mc.add(new Hammer.Pinch({ threshold: 0 })).recognizeWith([mc.get('pan'), mc.get('rotate')]);
            //结束时做一些处理
            mc.on("hammer.input", function (ev) {
                if (ev.isFinal) {
                    console.log(START_X + " " + transform.translate.x + " " + ev.deltaX);
                    START_X = transform.translate.x;
                    START_Y = transform.translate.y;
                }

            });
            mc.on("panstart panmove", onPan);
            mc.on("rotatestart rotatemove rotateend", onRotate);
            mc.on("pinchstart pinchmove", onPinch);
            /**
            第二次进入拖拽时 delta位移重置
            移动时 初始位置startxy不动。delta增加
            */
            function onPan(ev) {
                if (!ev.isFinal) {
                    $(drag).removeClass('animate');
                    console.log(START_X + " " + START_Y + " | " + ev.deltaX + " " + ev.deltaY);
                    transform.translate = {
                        x: START_X + ev.deltaX,
                        y: START_Y + ev.deltaY
                    };
                    requestElementUpdate();
                }
            }

            function onPinch(ev) {
                if (ev.type == 'pinchstart') {
                    initScale = transform.scale || 1;
                }
                $(drag).removeClass('animate');
                transform.scale = initScale * ev.scale;
                requestElementUpdate();
            }

            //旋转相关
            var preAngle = 0;
            var tempAngleFlag = 0;
            var deltaAngle = 0;
            var startRotateAngle = 0;

            function onRotate(ev) {
                //点下第二个触控点时触发
                if (ev.type == 'rotatestart') {
                    startRotateAngle = ev.rotation;
                    tempAngleFlag = 0;
                }
                if (ev.type == 'rotatemove') {
                    if (tempAngleFlag == 0) {
                        preAngle = startRotateAngle;
                        tempAngleFlag++;
                    } else {
                        deltaAngle = ev.rotation - preAngle;
                        $(drag).removeClass('animate');
                        transform.rz = 1; //非0 垂直xy轴
                        transform.angle = initAngle + deltaAngle;
                        requestElementUpdate();
                    }
                }

                //旋转结束 记录当前图片角度 
                if (ev.type == 'rotateend') {
                    initAngle = transform.angle;
                }
            }


            function updateElementTransform() {
                var value = [
                    'translate3d(' + transform.translate.x + 'px, ' + transform.translate.y + 'px, 0)',
                    'scale(' + transform.scale + ', ' + transform.scale + ')',
                    'rotate3d(' + transform.rx + ',' + transform.ry + ',' + transform.rz + ',' + transform.angle + 'deg)'
                ];

                value = value.join(" ");
                el.style.webkitTransform = value; /*为Chrome/Safari*/
                el.style.mozTransform = value; /*为Firefox*/
                el.style.transform = value; /*IE Opera?*/
                ticking = false;
            }

            function requestElementUpdate() {
                if (!ticking) {
                    reqAnimationFrame(updateElementTransform);
                    ticking = true;
                }
            }

            /**
            初始化设置
            */
            function resetElement() {

                el.className += ' animate';
                transform = {
                    translate: { x: START_X, y: START_Y },
                    scale: 1,
                    angle: 0,
                    rx: 0,
                    ry: 0,
                    rz: 0
                };
                requestElementUpdate();
            }

            resetElement();
        }
    </script>
</body>
</html>